ctx->xch = xc_interface_open(lg,lg,0);
if (!ctx->xch) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, errno,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno,
"cannot open libxc handle");
return ERROR_FAIL;
}
if (!ctx->xsh)
ctx->xsh = xs_domain_open();
if (!ctx->xsh) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, errno,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno,
"cannot connect to xenstore");
xc_interface_close(ctx->xch);
return ERROR_FAIL;
ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid);
if (ret < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "domain creation fail");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "domain creation fail");
libxl__free_all(&gc);
return ERROR_FAIL;
}
ret = xc_cpupool_movedomain(ctx->xch, info->poolid, *domid);
if (ret < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "domain move fail");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "domain move fail");
libxl__free_all(&gc);
return ERROR_FAIL;
}
vm_path = libxl__sprintf(&gc, "/vm/%s", uuid_string);
if (!vm_path) {
- XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate create paths");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot allocate create paths");
libxl__free_all(&gc);
return ERROR_FAIL;
}
if (!trans) {
trans = our_trans = xs_transaction_start(ctx->xsh);
if (!our_trans) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, errno,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno,
"create xs transaction for domain (re)name");
goto x_fail;
}
if (old_name) {
got_old_name = xs_read(ctx->xsh, trans, name_path, &got_old_len);
if (!got_old_name) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, errno, "check old name"
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno, "check old name"
" for domain %"PRIu32" allegedly named `%s'",
domid, old_name);
goto x_fail;
}
if (strcmp(old_name, got_old_name)) {
- XL_LOG(ctx, XL_LOG_ERROR, "domain %"PRIu32" allegedly named "
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "domain %"PRIu32" allegedly named "
"`%s' is actually named `%s' - racing ?",
domid, old_name, got_old_name);
free(got_old_name);
}
if (!xs_write(ctx->xsh, trans, name_path,
new_name, strlen(new_name))) {
- XL_LOG(ctx, XL_LOG_ERROR, "failed to write new name `%s'"
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to write new name `%s'"
" for domain %"PRIu32" previously named `%s'",
new_name, domid, old_name);
goto x_fail;
if (!xs_transaction_end(ctx->xsh, our_trans, 0)) {
trans = our_trans = 0;
if (errno != EAGAIN) {
- XL_LOG(ctx, XL_LOG_ERROR, "failed to commit new name `%s'"
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to commit new name `%s'"
" for domain %"PRIu32" previously named `%s'",
new_name, domid, old_name);
goto x_fail;
}
- XL_LOG(ctx, XL_LOG_DEBUG, "need to retry rename transaction"
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "need to retry rename transaction"
" for domain %"PRIu32" (name_path=\"%s\", new_name=\"%s\")",
domid, name_path, new_name);
goto retry_transaction;
struct timeval start_time;
int i, ret;
- ret = build_pre(ctx, domid, info, state);
+ ret = libxl__build_pre(ctx, domid, info, state);
if (ret)
goto out;
gettimeofday(&start_time, NULL);
if (info->hvm) {
- ret = build_hvm(ctx, domid, info, state);
+ ret = libxl__build_hvm(ctx, domid, info, state);
if (ret)
goto out;
vments[4] = "start_time";
vments[5] = libxl__sprintf(&gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
} else {
- ret = build_pv(ctx, domid, info, state);
+ ret = libxl__build_pv(ctx, domid, info, state);
if (ret)
goto out;
vments[i++] = (char*) info->u.pv.cmdline;
}
}
- ret = build_post(ctx, domid, info, state, vments, localents);
+ ret = libxl__build_post(ctx, domid, info, state, vments, localents);
out:
libxl__file_reference_unmap(&info->kernel);
if (!info->hvm)
struct timeval start_time;
int i, ret, esave, flags;
- ret = build_pre(ctx, domid, info, state);
+ ret = libxl__build_pre(ctx, domid, info, state);
if (ret)
goto out;
- ret = restore_common(ctx, domid, info, state, fd);
+ ret = libxl__domain_restore_common(ctx, domid, info, state, fd);
if (ret)
goto out;
vments[i++] = (char*) info->u.pv.cmdline;
}
}
- ret = build_post(ctx, domid, info, state, vments, localents);
+ ret = libxl__build_post(ctx, domid, info, state, vments, localents);
if (ret)
goto out;
flags = fcntl(fd, F_GETFL);
if (flags == -1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to get flags on restore fd");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to get flags on restore fd");
} else {
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1)
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to put restore fd"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to put restore fd"
" back to blocking mode");
}
libxl_gc gc = LIBXL_INIT_GC(ctx);
int rc = 0;
- if (is_hvm(ctx, domid)) {
- XL_LOG(ctx, XL_LOG_DEBUG, "Called domain_resume on "
+ if (libxl__domain_is_hvm(ctx, domid)) {
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Called domain_resume on "
"non-cooperative hvm domain %u", domid);
rc = ERROR_NI;
goto out;
}
if (xc_domain_resume(ctx->xch, domid, 1)) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
"xc_domain_resume failed for domain %u",
domid);
rc = ERROR_FAIL;
goto out;
}
if (!xs_resume_domain(ctx->xsh, domid)) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
"xs_resume_domain failed for domain %u",
domid);
rc = ERROR_FAIL;
ptr = calloc(size, sizeof(libxl_dominfo));
if (!ptr) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "allocating domain info");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating domain info");
return NULL;
}
ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "geting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
return NULL;
}
ret = xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "geting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
return ERROR_FAIL;
}
if (ret==0 || xcinfo.domain != domid) return ERROR_INVAL;
ptr = calloc(size, sizeof(libxl_poolinfo));
if (!ptr) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "allocating cpupool info");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating cpupool info");
return NULL;
}
ret = xc_cpupool_getinfo(ctx->xch, 0, 256, info);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting cpupool info");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting cpupool info");
return NULL;
}
ret = xc_domain_getinfolist(ctx->xch, 1, 1024, info);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "geting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "geting domain info list");
return NULL;
}
for (index = i = 0; i < ret; i++) {
int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
uint32_t domid, int fd)
{
- int hvm = is_hvm(ctx, domid);
+ int hvm = libxl__domain_is_hvm(ctx, domid);
int live = info != NULL && info->flags & XL_SUSPEND_LIVE;
int debug = info != NULL && info->flags & XL_SUSPEND_DEBUG;
int rc = 0;
- core_suspend(ctx, domid, fd, hvm, live, debug);
+ libxl__domain_suspend_common(ctx, domid, fd, hvm, live, debug);
if (hvm)
- rc = save_device_model(ctx, domid, fd);
+ rc = libxl__domain_save_device_model(ctx, domid, fd);
return rc;
}
int ret;
ret = xc_domain_pause(ctx->xch, domid);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "pausing domain %d", domid);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "pausing domain %d", domid);
return ERROR_FAIL;
}
return 0;
int ret;
ret = xc_domain_dumpcore(ctx->xch, domid, filename);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "core dumping domain %d to %s",
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "core dumping domain %d to %s",
domid, filename);
return ERROR_FAIL;
}
char *state;
int ret, rc = 0;
- if (is_hvm(ctx, domid)) {
+ if (libxl__domain_is_hvm(ctx, domid)) {
path = libxl__sprintf(&gc, "/local/domain/0/device-model/%d/state", domid);
state = libxl__xs_read(&gc, XBT_NULL, path);
if (state != NULL && !strcmp(state, "paused")) {
}
ret = xc_domain_unpause(ctx->xch, domid);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unpausing domain %d", domid);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
rc = ERROR_FAIL;
}
libxl__free_all(&gc);
shutdown_path = libxl__sprintf(&gc, "%s/control/shutdown", dom_path);
xs_write(ctx->xsh, XBT_NULL, shutdown_path, req_table[req], strlen(req_table[req]));
- if (is_hvm(ctx,domid)) {
+ if (libxl__domain_is_hvm(ctx,domid)) {
unsigned long acpi_s_state = 0;
unsigned long pvdriver = 0;
int ret;
ret = xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_ACPI_S_STATE, &acpi_s_state);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting ACPI S-state");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting ACPI S-state");
return ERROR_FAIL;
}
ret = xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting HVM callback IRQ");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting HVM callback IRQ");
return ERROR_FAIL;
}
if (!pvdriver || acpi_s_state != 0) {
ret = xc_domain_shutdown(ctx->xch, domid, req);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unpausing domain");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain");
return ERROR_FAIL;
}
}
for (i = 0; i < num_disks; i++) {
if (asprintf(&(waiter[i].path), "%s/device/vbd/%d/eject",
libxl__xs_get_dompath(&gc, domid),
- device_disk_dev_number(disks[i].virtpath)) < 0)
+ libxl__device_disk_dev_number(disks[i].virtpath)) < 0)
goto out;
if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0)
goto out;
if (!pid) {
int stubdomid = libxl_get_stubdom_id(ctx, domid);
if (!stubdomid) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't find device model's pid");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't find device model's pid");
ret = ERROR_INVAL;
goto out;
}
- XL_LOG(ctx, XL_LOG_ERROR, "Device model is a stubdom, domid=%d\n", stubdomid);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device model is a stubdom, domid=%d\n", stubdomid);
ret = libxl_domain_destroy(ctx, stubdomid, 0);
goto out;
}
ret = kill(atoi(pid), SIGHUP);
if (ret < 0 && errno == ESRCH) {
- XL_LOG(ctx, XL_LOG_DEBUG, "Device Model already exited");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model already exited");
ret = 0;
} else if (ret == 0) {
- XL_LOG(ctx, XL_LOG_DEBUG, "Device Model signaled");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model signaled");
ret = 0;
} else {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to kill Device Model [%d]",
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to kill Device Model [%d]",
atoi(pid));
}
out:
char *vm_path;
int rc, dm_present;
- if (is_hvm(ctx, domid)) {
+ if (libxl__domain_is_hvm(ctx, domid)) {
dm_present = 1;
} else {
char *pid;
}
if (libxl_device_pci_shutdown(ctx, domid) < 0)
- XL_LOG(ctx, XL_LOG_ERROR, "pci shutdown failed for domid %d", domid);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "pci shutdown failed for domid %d", domid);
if (dm_present) {
xs_write(ctx->xsh, XBT_NULL,
libxl__sprintf(&gc, "/local/domain/0/device-model/%d/command", domid),
}
rc = xc_domain_pause(ctx->xch, domid);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_pause failed for %d", domid);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_pause failed for %d", domid);
}
if (dm_present) {
if (libxl_destroy_device_model(ctx, domid) < 0)
- XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_device_model failed for %d", domid);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl_destroy_device_model failed for %d", domid);
}
if (libxl__devices_destroy(ctx, domid, force) < 0)
- XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_devices failed for %d", domid);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl_destroy_devices failed for %d", domid);
vm_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/vm", dom_path));
if (vm_path)
if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xs_rm failed for %s", vm_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs_rm failed for %s", vm_path);
if (!xs_rm(ctx->xsh, XBT_NULL, dom_path))
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xs_rm failed for %s", dom_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs_rm failed for %s", dom_path);
libxl__userdata_destroyall(ctx, domid);
rc = xc_domain_destroy(ctx->xch, domid);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_destroy failed for %d", domid);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_destroy failed for %d", domid);
rc = ERROR_FAIL;
goto out;
}
if (stubdomid)
return libxl_console_exec(ctx, stubdomid, 1, LIBXL_CONSTYPE_PV);
else {
- if (is_hvm(ctx, domid_vm))
+ if (libxl__domain_is_hvm(ctx, domid_vm))
return libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_SERIAL);
else
return libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_PV);
if ( unlink(tmpname) )
/* should never happen */
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unlink %s failed", tmpname);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unlink %s failed", tmpname);
if ( libxl_write_exactly(ctx, autopass_fd, vnc_pass, strlen(vnc_pass),
tmpname, "vnc password") ) {
"%d", info->domid);
ret = xc_domain_set_target(ctx->xch, domid, info->domid);
if (ret<0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting target domain %d -> %d", domid, info->domid);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting target domain %d -> %d", domid, info->domid);
ret = ERROR_FAIL;
goto out_free;
}
goto out_free;
}
- backend_type = device_disk_backend_type_of_phystype(disk->phystype);
- devid = device_disk_dev_number(disk->virtpath);
+ backend_type = libxl__device_disk_backend_type_of_phystype(disk->phystype);
+ devid = libxl__device_disk_dev_number(disk->virtpath);
if (devid==-1) {
- XL_LOG(ctx, XL_LOG_ERROR, "Invalid or unsupported"
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
" virtual disk identifier %s", disk->virtpath);
rc = ERROR_INVAL;
goto out_free;
switch (disk->phystype) {
case PHYSTYPE_PHY: {
- device_physdisk_major_minor(disk->physpath, &major, &minor);
+ libxl__device_physdisk_major_minor(disk->physpath, &major, &minor);
flexarray_set(back, boffset++, "physical-device");
flexarray_set(back, boffset++, libxl__sprintf(&gc, "%x:%x", major, minor));
case PHYSTYPE_QCOW:
case PHYSTYPE_QCOW2:
case PHYSTYPE_VHD:
- if (libxl_blktap_enabled(&gc)) {
- const char *dev = libxl_blktap_devpath(&gc,
+ if (libxl__blktap_enabled(&gc)) {
+ const char *dev = libxl__blktap_devpath(&gc,
disk->physpath, disk->phystype);
if (!dev) {
rc = ERROR_FAIL;
goto out_free;
}
flexarray_set(back, boffset++, "tapdisk-params");
- flexarray_set(back, boffset++, libxl__sprintf(&gc, "%s:%s", device_disk_string_of_phystype(disk->phystype), disk->physpath));
+ flexarray_set(back, boffset++, libxl__sprintf(&gc, "%s:%s", libxl__device_disk_string_of_phystype(disk->phystype), disk->physpath));
flexarray_set(back, boffset++, "params");
flexarray_set(back, boffset++, libxl__strdup(&gc, dev));
backend_type = "phy";
- device_physdisk_major_minor(dev, &major, &minor);
+ libxl__device_physdisk_major_minor(dev, &major, &minor);
flexarray_set(back, boffset++, "physical-device");
flexarray_set(back, boffset++, libxl__sprintf(&gc, "%x:%x", major, minor));
device.backend_kind = DEVICE_VBD;
}
flexarray_set(back, boffset++, "params");
flexarray_set(back, boffset++, libxl__sprintf(&gc, "%s:%s",
- device_disk_string_of_phystype(disk->phystype), disk->physpath));
+ libxl__device_disk_string_of_phystype(disk->phystype), disk->physpath));
device.backend_kind = DEVICE_TAP;
break;
default:
- XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", disk->phystype);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk physical type: %d\n", disk->phystype);
rc = ERROR_INVAL;
goto out_free;
}
libxl_device device;
int devid;
- devid = device_disk_dev_number(disk->virtpath);
+ devid = libxl__device_disk_dev_number(disk->virtpath);
device.backend_domid = disk->backend_domid;
device.backend_devid = devid;
device.backend_kind =
case PHYSTYPE_QCOW:
case PHYSTYPE_QCOW2:
case PHYSTYPE_VHD:
- if (libxl_blktap_enabled(&gc))
- dev = libxl_blktap_devpath(&gc, disk->physpath, phystype);
+ if (libxl__blktap_enabled(&gc))
+ dev = libxl__blktap_devpath(&gc, disk->physpath, phystype);
break;
default:
- XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", phystype);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk physical type: %d\n", phystype);
break;
}
ret = strdup(dev);
char *val;
dompath = libxl__xs_get_dompath(&gc, domid);
- diskinfo->devid = device_disk_dev_number(disk->virtpath);
+ diskinfo->devid = libxl__device_disk_dev_number(disk->virtpath);
/* tap devices entries in xenstore are written as vbd devices. */
diskpath = libxl__sprintf(&gc, "%s/device/vbd/%d", dompath, diskinfo->devid);
break;
}
if (i == num) {
- XL_LOG(ctx, XL_LOG_ERROR, "Virtual device not found");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual device not found");
goto out;
}
mem = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/memory/target", dompath));
if (!mem) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot get memory info from %s/memory/target\n", dompath);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "cannot get memory info from %s/memory/target\n", dompath);
goto out;
}
memorykb = strtoul(mem, &endptr, 10);
if (*endptr != '\0') {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "invalid memory %s from %s/memory/target\n", mem, dompath);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "invalid memory %s from %s/memory/target\n", mem, dompath);
goto out;
}
if (max_memkb < memorykb) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "memory_static_max must be greater than or or equal to memory_dynamic_max\n");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "memory_static_max must be greater than or or equal to memory_dynamic_max\n");
goto out;
}
if (domid) {
memmax = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/memory/static-max", dompath));
if (!memmax) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
"cannot get memory info from %s/memory/static-max\n", dompath);
goto out;
}
memorykb = strtoul(memmax, &endptr, 10);
if (*endptr != '\0') {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
"invalid max memory %s from %s/memory/static-max\n", memmax, dompath);
goto out;
}
if (target_memkb > memorykb) {
- XL_LOG(ctx, XL_LOG_ERROR,
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"memory_dynamic_max must be less than or equal to memory_static_max\n");
goto out;
}
rc = xc_physinfo(ctx->xch, &xcphysinfo);
if (rc != 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting physinfo");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting physinfo");
return ERROR_FAIL;
}
physinfo->threads_per_core = xcphysinfo.threads_per_core;
unsigned num_cpuwords;
if (xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo) != 1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting infolist");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting infolist");
return NULL;
}
if (xc_physinfo(ctx->xch, &physinfo) == -1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting physinfo");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting physinfo");
return NULL;
}
*nrcpus = physinfo.max_cpu_id + 1;
return NULL;
}
if (xc_vcpu_getinfo(ctx->xch, domid, *nb_vcpu, &vcpuinfo) == -1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu info");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting vcpu info");
return NULL;
}
if (xc_vcpu_getaffinity(ctx->xch, domid, *nb_vcpu,
ptr->cpumap, ((*nrcpus) + 7) / 8) == -1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu affinity");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting vcpu affinity");
return NULL;
}
ptr->vcpuid = *nb_vcpu;
uint64_t *cpumap, int nrcpus)
{
if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, (nrcpus + 7) / 8)) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting vcpu affinity");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting vcpu affinity");
return ERROR_FAIL;
}
return 0;
int i, rc = ERROR_FAIL;
if (libxl_domain_info(ctx, &info, domid) < 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
goto out;
}
if (!(dompath = libxl__xs_get_dompath(&gc, domid)))
int sched, ret;
if ((ret = xc_sched_id(ctx->xch, &sched)) != 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
return ERROR_FAIL;
}
return sched;
rc = xc_sched_credit_domain_get(ctx->xch, domid, &sdom);
if (rc != 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting domain sched credit");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting domain sched credit");
return ERROR_FAIL;
}
rc = xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo);
if (rc < 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting domain info list");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
return ERROR_FAIL;
}
if (rc != 1 || domaininfo.domain != domid)
if (scinfo->weight < 1 || scinfo->weight > 65535) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Cpu weight out of range, valid values are within range from 1 to 65535");
return ERROR_INVAL;
}
if (scinfo->cap < 0 || scinfo->cap > (domaininfo.max_vcpu_id + 1) * 100) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Cpu cap out of range, valid range is from 0 to %d for specified number of vcpus",
((domaininfo.max_vcpu_id + 1) * 100));
return ERROR_INVAL;
rc = xc_sched_credit_domain_set(ctx->xch, domid, &sdom);
if ( rc < 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting domain sched credit");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting domain sched credit");
return ERROR_FAIL;
}
int trigger_type = trigger_type_from_string(trigger_name);
if (trigger_type == -1) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, -1,
"Invalid trigger, valid triggers are <nmi|reset|init|power|sleep>");
return ERROR_INVAL;
}
rc = xc_domain_send_trigger(ctx->xch, domid, trigger_type, vcpuid);
if (rc != 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Send trigger '%s' failed", trigger_name);
return ERROR_FAIL;
}
int ret;
ret = xc_send_debug_keys(ctx->xch, keys);
if ( ret < 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "sending debug keys");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "sending debug keys");
return ERROR_FAIL;
}
return 0;
char *buf = malloc(size);
if (!buf) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot malloc buffer for libxl_xen_console_reader,"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "cannot malloc buffer for libxl_xen_console_reader,"
" size is %u", size);
return NULL;
}
cr = malloc(sizeof(libxl_xen_console_reader));
if (!cr) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot malloc libxl_xen_console_reader");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "cannot malloc libxl_xen_console_reader");
return NULL;
}
ret = xc_readconsolering(ctx->xch, &cr->buffer, &cr->count,
cr->clear, cr->incremental, &cr->index);
if (ret < 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "reading console ring buffer");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "reading console ring buffer");
return ERROR_FAIL;
}
if (!ret) {
start_time = libxl__xs_read(
&gc, XBT_NULL, libxl__sprintf(&gc, "%s/start_time", vm_path));
if (start_time == NULL) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, -1,
"Can't get start time of domain '%d'", domid);
ret = -1;
}else{
rc = xc_tmem_control(ctx->xch, -1, TMEMC_LIST, domid, 32768, use_long,
0, _buf);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not get tmem list");
return NULL;
}
rc = xc_tmem_control(ctx->xch, -1, TMEMC_FREEZE, domid, 0, 0,
0, NULL);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not freeze tmem pools");
return ERROR_FAIL;
}
rc = xc_tmem_control(ctx->xch, -1, TMEMC_DESTROY, domid, 0, 0,
0, NULL);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not destroy tmem pools");
return ERROR_FAIL;
}
rc = xc_tmem_control(ctx->xch, -1, TMEMC_THAW, domid, 0, 0,
0, NULL);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not thaw tmem pools");
return ERROR_FAIL;
}
int32_t subop = tmem_setop_from_string(name);
if (subop == -1) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, -1,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, -1,
"Invalid set, valid sets are <weight|cap|compress>");
return ERROR_INVAL;
}
rc = xc_tmem_control(ctx->xch, -1, subop, domid, set, 0, 0, NULL);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not set tmem %s", name);
return ERROR_FAIL;
}
rc = xc_tmem_auth(ctx->xch, domid, uuid, auth);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not set tmem shared auth");
return ERROR_FAIL;
}
rc = xc_tmem_control(ctx->xch, -1, TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, 0);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Can not get tmem freeable memory");
return ERROR_FAIL;
}
#include "tap-ctl.h"
-int libxl_blktap_enabled(libxl_gc *gc)
+int libxl__blktap_enabled(libxl_gc *gc)
{
const char *msg;
return !tap_ctl_check(&msg);
}
-const char *libxl_blktap_devpath(libxl_gc *gc,
+const char *libxl__blktap_devpath(libxl_gc *gc,
const char *disk,
libxl_disk_phystype phystype)
{
char *params, *devname = NULL;
int minor, err;
- type = device_disk_string_of_phystype(phystype);
+ type = libxl__device_disk_string_of_phystype(phystype);
minor = tap_ctl_find_minor(type, disk);
if (minor >= 0) {
devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor);
if (errno == EAGAIN)
goto retry_transaction;
else
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xs transaction failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs transaction failed");
}
rc = 0;
out:
return rc;
}
-char *device_disk_string_of_phystype(libxl_disk_phystype phystype)
+char *libxl__device_disk_string_of_phystype(libxl_disk_phystype phystype)
{
switch (phystype) {
case PHYSTYPE_QCOW: return "qcow";
}
}
-char *device_disk_backend_type_of_phystype(libxl_disk_phystype phystype)
+char *libxl__device_disk_backend_type_of_phystype(libxl_disk_phystype phystype)
{
switch (phystype) {
case PHYSTYPE_QCOW: return "tap";
}
}
-int device_physdisk_major_minor(const char *physpath, int *major, int *minor)
+int libxl__device_physdisk_major_minor(const char *physpath, int *major, int *minor)
{
struct stat buf;
if (stat(physpath, &buf) < 0)
return 1;
}
-int device_disk_dev_number(char *virtpath)
+int libxl__device_disk_dev_number(char *virtpath)
{
int disk, partition;
char *ep;
if (!state || atoi(state) == 6) {
xs_unwatch(ctx->xsh, l1[0], l1[1]);
xs_rm(ctx->xsh, XBT_NULL, l1[XS_WATCH_TOKEN]);
- XL_LOG(ctx, XL_LOG_DEBUG, "Destroyed device backend at %s", l1[XS_WATCH_TOKEN]);
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Destroyed device backend at %s", l1[XS_WATCH_TOKEN]);
rc = 0;
}
free(l1);
path = libxl__sprintf(&gc, "/local/domain/%d/device", domid);
l1 = libxl__xs_directory(&gc, XBT_NULL, path, &num1);
if (!l1) {
- XL_LOG(ctx, XL_LOG_ERROR, "%s is empty", path);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "%s is empty", path);
goto out;
}
for (i = 0; i < num1; i++) {
}
xs_unwatch(xsh, path, path);
xs_daemon_close(xsh);
- XL_LOG(ctx, XL_LOG_ERROR, "Device Model not ready");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model not ready");
libxl__free_all(&gc);
return -1;
}
p = xs_read(ctx->xsh, XBT_NULL, path, &len);
if (p == NULL) {
if (errno == ENOENT) {
- XL_LOG(ctx, XL_LOG_ERROR, "Backend %s does not exist",
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Backend %s does not exist",
be_path);
} else {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access backend %s",
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access backend %s",
be_path);
}
goto out;
}
}
}
- XL_LOG(ctx, XL_LOG_ERROR, "Backend %s not ready", be_path);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Backend %s not ready", be_path);
out:
libxl__free_all(&gc);
return rc;
#include "libxl.h"
#include "libxl_internal.h"
-int is_hvm(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_is_hvm(libxl_ctx *ctx, uint32_t domid)
{
xc_domaininfo_t info;
int ret;
return !!(info.flags & XEN_DOMINF_hvm_guest);
}
-int get_shutdown_reason(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_shutdown_reason(libxl_ctx *ctx, uint32_t domid)
{
xc_domaininfo_t info;
int ret;
return -1;
if (!(info.flags & XEN_DOMINF_shutdown))
return -1;
- return dominfo_get_shutdown_reason(&info);
+
+ return (info.flags >> XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask;
}
-int build_pre(libxl_ctx *ctx, uint32_t domid,
+int libxl__build_pre(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state)
{
xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
return 0;
}
-int build_post(libxl_ctx *ctx, uint32_t domid,
+int libxl__build_post(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state,
char **vms_ents, char **local_ents)
{
return 0;
}
-int build_pv(libxl_ctx *ctx, uint32_t domid,
+int libxl__build_pv(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state)
{
struct xc_dom_image *dom;
dom = xc_dom_allocate(ctx->xch, info->u.pv.cmdline, info->u.pv.features);
if (!dom) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_allocate failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed");
return ERROR_FAIL;
}
if (info->kernel.mapped) {
if ( (ret = xc_dom_kernel_mem(dom, info->kernel.data, info->kernel.size)) != 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_kernel_mem failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed");
goto out;
}
} else {
if ( (ret = xc_dom_kernel_file(dom, info->kernel.path)) != 0) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_kernel_file failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed");
goto out;
}
}
if ( info->u.pv.ramdisk.path && strlen(info->u.pv.ramdisk.path) ) {
if (info->u.pv.ramdisk.mapped) {
if ( (ret = xc_dom_ramdisk_mem(dom, info->u.pv.ramdisk.data, info->u.pv.ramdisk.size)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_ramdisk_mem failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_mem failed");
goto out;
}
} else {
if ( (ret = xc_dom_ramdisk_file(dom, info->u.pv.ramdisk.path)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_ramdisk_file failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_file failed");
goto out;
}
}
dom->xenstore_evtchn = state->store_port;
if ( (ret = xc_dom_boot_xen_init(dom, ctx->xch, domid)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_boot_xen_init failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_xen_init failed");
goto out;
}
if ( (ret = xc_dom_parse_image(dom)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_parse_image failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_parse_image failed");
goto out;
}
if ( (ret = xc_dom_mem_init(dom, info->target_memkb / 1024)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_mem_init failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_mem_init failed");
goto out;
}
if ( (ret = xc_dom_boot_mem_init(dom)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_boot_mem_init failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_mem_init failed");
goto out;
}
if ( (ret = xc_dom_build_image(dom)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_build_image failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_build_image failed");
goto out;
}
if ( (ret = xc_dom_boot_image(dom)) != 0 ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_boot_image failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_image failed");
goto out;
}
return ret == 0 ? 0 : ERROR_FAIL;
}
-int build_hvm(libxl_ctx *ctx, uint32_t domid,
+int libxl__build_hvm(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state)
{
libxl_gc gc = LIBXL_INIT_GC(ctx);
int ret, rc = ERROR_INVAL;
if (info->kernel.mapped) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "build_hvm kernel cannot be mmapped");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "libxl__build_hvm kernel cannot be mmapped");
goto out;
}
libxl__abs_path(&gc, (char *)info->kernel.path,
libxl_xenfirmwaredir_path()));
if (ret) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm building failed");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed");
goto out;
}
ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
&state->store_mfn, state->console_port, &state->console_mfn);
if (ret) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params failed");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm build set params failed");
goto out;
}
rc = 0;
return 0;
}
-int restore_common(libxl_ctx *ctx, uint32_t domid,
+int libxl__domain_restore_common(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state,
int fd)
{
state->console_port, &state->console_mfn,
info->hvm, info->u.hvm.pae, 0);
if ( rc ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "restoring domain");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "restoring domain");
return ERROR_FAIL;
}
return 0;
unsigned int flags;
};
-static void core_suspend_switch_qemu_logdirty(int domid, unsigned int enable)
+static void libxl__domain_suspend_common_switch_qemu_logdirty(int domid, unsigned int enable)
{
struct xs_handle *xsh;
char path[64];
xs_daemon_close(xsh);
}
-static int core_suspend_callback(void *data)
+static int libxl__domain_suspend_common_callback(void *data)
{
struct suspendinfo *si = data;
unsigned long s_state = 0;
if ((s_state == 0) && (si->suspend_eventchn >= 0)) {
ret = xc_evtchn_notify(si->xce, si->suspend_eventchn);
if (ret < 0) {
- XL_LOG(ctx, XL_LOG_ERROR, "xc_evtchn_notify failed ret=%d", ret);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "xc_evtchn_notify failed ret=%d", ret);
return 0;
}
ret = xc_await_suspend(ctx->xch, si->xce, si->suspend_eventchn);
if (ret < 0) {
- XL_LOG(ctx, XL_LOG_ERROR, "xc_await_suspend failed ret=%d", ret);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "xc_await_suspend failed ret=%d", ret);
return 0;
}
return 1;
xc_get_hvm_param(ctx->xch, si->domid, HVM_PARAM_CALLBACK_IRQ, &hvm_pvdrv);
xc_get_hvm_param(ctx->xch, si->domid, HVM_PARAM_ACPI_S_STATE, &hvm_s_state);
if (!hvm_pvdrv || hvm_s_state) {
- XL_LOG(ctx, XL_LOG_DEBUG, "Calling xc_domain_shutdown on the domain");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Calling xc_domain_shutdown on the domain");
xc_domain_shutdown(ctx->xch, si->domid, SHUTDOWN_suspend);
}
}
- XL_LOG(ctx, XL_LOG_DEBUG, "wait for the guest to suspend");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "wait for the guest to suspend");
while (!strcmp(state, "suspend") && watchdog > 0) {
xc_domaininfo_t info;
watchdog--;
}
if (!strcmp(state, "suspend")) {
- XL_LOG(ctx, XL_LOG_ERROR, "guest didn't suspend in time");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "guest didn't suspend in time");
libxl__xs_write(si->gc, XBT_NULL, path, "");
}
return 1;
}
-int core_suspend(libxl_ctx *ctx, uint32_t domid, int fd,
+int libxl__domain_suspend_common(libxl_ctx *ctx, uint32_t domid, int fd,
int hvm, int live, int debug)
{
libxl_gc gc = LIBXL_INIT_GC(ctx);
si.suspend_eventchn = xc_suspend_evtchn_init(ctx->xch, si.xce, si.domid, port);
if (si.suspend_eventchn < 0)
- XL_LOG(ctx, XL_LOG_WARNING, "Suspend event channel initialization failed");
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "Suspend event channel initialization failed");
}
}
memset(&callbacks, 0, sizeof(callbacks));
- callbacks.suspend = core_suspend_callback;
+ callbacks.suspend = libxl__domain_suspend_common_callback;
callbacks.data = &si;
xc_domain_save(ctx->xch, fd, domid, 0, 0, flags,
&callbacks, hvm,
- &core_suspend_switch_qemu_logdirty);
+ &libxl__domain_suspend_common_switch_qemu_logdirty);
if (si.suspend_eventchn > 0)
xc_suspend_evtchn_release(ctx->xch, si.xce, domid, si.suspend_eventchn);
return rc;
}
-int save_device_model(libxl_ctx *ctx, uint32_t domid, int fd)
+int libxl__domain_save_device_model(libxl_ctx *ctx, uint32_t domid, int fd)
{
libxl_gc gc = LIBXL_INIT_GC(ctx);
int fd2, c;
char buf[1024];
char *filename = libxl__sprintf(&gc, "/var/lib/xen/qemu-save.%d", domid);
- XL_LOG(ctx, XL_LOG_DEBUG, "Saving device model state to %s", filename);
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Saving device model state to %s", filename);
libxl__xs_write(&gc, XBT_NULL, libxl__sprintf(&gc, "/local/domain/0/device-model/%d/command", domid), "save");
libxl__wait_for_device_model(ctx, domid, "paused", NULL, NULL);
{
char *s = libxl__sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
if (!s)
- XL_LOG(libxl_gc_owner(gc), XL_LOG_ERROR, "cannot allocate for uuid");
+ LIBXL__LOG(libxl_gc_owner(gc), LIBXL__LOG_ERROR, "cannot allocate for uuid");
return s;
}
rc = libxl_domain_info(ctx, &info, domid);
if (rc) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to find domain info"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to find domain info"
" for domain %"PRIu32, domid);
return NULL;
}
"userdata-%s.%u.%s.%s",
wh, domid, uuid_string, userdata_userid);
if (!path)
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to allocate for"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to allocate for"
" userdata path");
return path;
}
int r;
r = unlink(path);
if (r) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "remove failed for %s", path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "remove failed for %s", path);
return errno;
}
return 0;
if (r == GLOB_NOMATCH)
goto out;
if (r)
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "glob failed for %s", pattern);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "glob failed for %s", pattern);
for (i=0; i<gl.gl_pathc; i++) {
userdata_delete(ctx, gl.gl_pathv[i]);
errno = e;
if ( rc )
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "cannot write %s for %s",
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "cannot write %s for %s",
newfilename, filename);
out:
libxl__free_all(&gc);
e = libxl_read_file_contents(ctx, filename, data_r ? &data : 0, &datalen);
if (!e && !datalen) {
- XL_LOG(ctx, XL_LOG_ERROR, "userdata file %s is empty", filename);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "userdata file %s is empty", filename);
if (data_r) assert(!*data_r);
rc = ERROR_FAIL;
goto out;
if (WIFEXITED(status)) {
int st = WEXITSTATUS(status);
if (st)
- XL_LOG(ctx, level, "%s [%ld] exited"
+ LIBXL__LOG(ctx, level, "%s [%ld] exited"
" with error status %d", what, (unsigned long)pid, st);
else
- XL_LOG(ctx, level, "%s [%ld] unexpectedly"
+ LIBXL__LOG(ctx, level, "%s [%ld] unexpectedly"
" exited status zero", what, (unsigned long)pid);
} else if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
const char *str = strsignal(sig);
const char *coredump = WCOREDUMP(status) ? " (core dumped)" : "";
if (str)
- XL_LOG(ctx, level, "%s [%ld] died due to"
+ LIBXL__LOG(ctx, level, "%s [%ld] died due to"
" fatal signal %s%s", what, (unsigned long)pid,
str, coredump);
else
- XL_LOG(ctx, level, "%s [%ld] died due to unknown"
+ LIBXL__LOG(ctx, level, "%s [%ld] died due to unknown"
" fatal signal number %d%s", what, (unsigned long)pid,
sig, coredump);
} else {
- XL_LOG(ctx, level, "%s [%ld] gave unknown"
+ LIBXL__LOG(ctx, level, "%s [%ld] gave unknown"
" wait status 0x%x", what, (unsigned long)pid, status);
}
}
"%s intermediate process (startup monitor)",
for_spawn->what) < 0 )
intermediate_what = "intermediate process (startup monitor)";
- libxl_report_child_exitstatus(ctx, XL_LOG_ERROR, intermediate_what,
+ libxl_report_child_exitstatus(ctx, LIBXL__LOG_ERROR, intermediate_what,
for_spawn->intermediate, status);
}
}
if (for_spawn->intermediate) {
r = kill(for_spawn->intermediate, SIGKILL);
if (r) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
"could not kill %s intermediate process [%ld]",
for_spawn->what,
(unsigned long)for_spawn->intermediate);
return ptr;
}
-void xl_logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
const char *file, int line, const char *func,
char *fmt, va_list ap)
{
errno = esave;
}
-void xl_log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
const char *file, int line, const char *func,
char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- xl_logv(ctx, msglevel, errnoval, file, line, func, fmt, ap);
+ libxl__logv(ctx, msglevel, errnoval, file, line, func, fmt, ap);
va_end(ap);
}
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define XL_LOGGING_ENABLED
+#define LIBXL__LOGGING_ENABLED
-#ifdef XL_LOGGING_ENABLED
-#define XL_LOG(ctx, loglevel, _f, _a...) xl_log(ctx, loglevel, -1, __FILE__, __LINE__, __func__, _f, ##_a)
-#define XL_LOG_ERRNO(ctx, loglevel, _f, _a...) xl_log(ctx, loglevel, errno, __FILE__, __LINE__, __func__, _f, ##_a)
-#define XL_LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...) xl_log(ctx, loglevel, errnoval, __FILE__, __LINE__, __func__, _f, ##_a)
+#ifdef LIBXL__LOGGING_ENABLED
+#define LIBXL__LOG(ctx, loglevel, _f, _a...) libxl__log(ctx, loglevel, -1, __FILE__, __LINE__, __func__, _f, ##_a)
+#define LIBXL__LOG_ERRNO(ctx, loglevel, _f, _a...) libxl__log(ctx, loglevel, errno, __FILE__, __LINE__, __func__, _f, ##_a)
+#define LIBXL__LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...) libxl__log(ctx, loglevel, errnoval, __FILE__, __LINE__, __func__, _f, ##_a)
#else
-#define XL_LOG(ctx, loglevel, _f, _a...)
-#define XL_LOG_ERRNO(ctx, loglevel, _f, _a...)
-#define XL_LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
+#define LIBXL__LOG(ctx, loglevel, _f, _a...)
+#define LIBXL__LOG_ERRNO(ctx, loglevel, _f, _a...)
+#define LIBXL__LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
#endif
/* all of these macros preserve errno (saving and restoring) */
/* logging */
-_hidden void xl_logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+_hidden void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
const char *file /* may be 0 */, int line /* ignored if !file */,
const char *func /* may be 0 */,
char *fmt, va_list al)
__attribute__((format(printf,7,0)));
-_hidden void xl_log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
+_hidden void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
const char *file /* may be 0 */, int line /* ignored if !file */,
const char *func /* may be 0 */,
char *fmt, ...)
_hidden char **libxl__xs_directory(libxl_gc *gc, xs_transaction_t t, char *path, unsigned int *nb);
/* from xl_dom */
-_hidden int is_hvm(libxl_ctx *ctx, uint32_t domid);
-_hidden int get_shutdown_reason(libxl_ctx *ctx, uint32_t domid);
-#define dominfo_get_shutdown_reason(info) (((info)->flags >> XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask)
+_hidden int libxl__domain_is_hvm(libxl_ctx *ctx, uint32_t domid);
+_hidden int libxl__domain_shutdown_reason(libxl_ctx *ctx, uint32_t domid);
-_hidden int build_pre(libxl_ctx *ctx, uint32_t domid,
+_hidden int libxl__build_pre(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state);
-_hidden int build_post(libxl_ctx *ctx, uint32_t domid,
+_hidden int libxl__build_post(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state,
char **vms_ents, char **local_ents);
-_hidden int build_pv(libxl_ctx *ctx, uint32_t domid,
+_hidden int libxl__build_pv(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state);
-_hidden int build_hvm(libxl_ctx *ctx, uint32_t domid,
+_hidden int libxl__build_hvm(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state);
-_hidden int restore_common(libxl_ctx *ctx, uint32_t domid,
+_hidden int libxl__domain_restore_common(libxl_ctx *ctx, uint32_t domid,
libxl_domain_build_info *info, libxl_domain_build_state *state, int fd);
-_hidden int core_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int hvm, int live, int debug);
-_hidden int save_device_model(libxl_ctx *ctx, uint32_t domid, int fd);
+_hidden int libxl__domain_suspend_common(libxl_ctx *ctx, uint32_t domid, int fd, int hvm, int live, int debug);
+_hidden int libxl__domain_save_device_model(libxl_ctx *ctx, uint32_t domid, int fd);
_hidden void libxl__userdata_destroyall(libxl_ctx *ctx, uint32_t domid);
/* from xl_device */
-_hidden char *device_disk_backend_type_of_phystype(libxl_disk_phystype phystype);
-_hidden char *device_disk_string_of_phystype(libxl_disk_phystype phystype);
+_hidden char *libxl__device_disk_backend_type_of_phystype(libxl_disk_phystype phystype);
+_hidden char *libxl__device_disk_string_of_phystype(libxl_disk_phystype phystype);
-_hidden int device_physdisk_major_minor(const char *physpath, int *major, int *minor);
-_hidden int device_disk_dev_number(char *virtpath);
+_hidden int libxl__device_physdisk_major_minor(const char *physpath, int *major, int *minor);
+_hidden int libxl__device_disk_dev_number(char *virtpath);
_hidden int libxl__device_generic_add(libxl_ctx *ctx, libxl_device *device,
char **bents, char **fents);
_hidden char *libxl__abs_path(libxl_gc *gc, char *s, const char *path);
-#define XL_LOG_DEBUG XTL_DEBUG
-#define XL_LOG_INFO XTL_INFO
-#define XL_LOG_WARNING XTL_WARN
-#define XL_LOG_ERROR XTL_ERROR
+#define LIBXL__LOG_DEBUG XTL_DEBUG
+#define LIBXL__LOG_INFO XTL_INFO
+#define LIBXL__LOG_WARNING XTL_WARN
+#define LIBXL__LOG_ERROR XTL_ERROR
_hidden char *libxl__domid_to_name(libxl_gc *gc, uint32_t domid);
_hidden char *libxl__poolid_to_name(libxl_gc *gc, uint32_t poolid);
* blktap2 support
*/
-/* libxl_blktap_enabled:
+/* libxl__blktap_enabled:
* return true if blktap/blktap2 support is available.
*/
-int libxl_blktap_enabled(libxl_gc *gc);
+_hidden int libxl__blktap_enabled(libxl_gc *gc);
-/* libxl_blktap_devpath:
+/* libxl__blktap_devpath:
* Argument: path and disk image as specified in config file.
* The type specifies whether this is aio, qcow, qcow2, etc.
* returns device path xenstore wants to have. returns NULL
* if no device corresponds to the disk.
*/
-const char *libxl_blktap_devpath(libxl_gc *gc,
+_hidden const char *libxl__blktap_devpath(libxl_gc *gc,
const char *disk,
libxl_disk_phystype phystype);
#include "libxl_osdeps.h"
#include "libxl_internal.h"
-int libxl_blktap_enabled(libxl_gc *gc)
+int libxl__blktap_enabled(libxl_gc *gc)
{
return 0;
}
-const char *libxl_blktap_devpath(libxl_gc *gc,
+const char *libxl__blktap_devpath(libxl_gc *gc,
const char *disk,
libxl_disk_phystype phystype)
{
}else if ( !strcmp(optkey, "power_mgmt") ) {
pcidev->power_mgmt = atoi(tok);
}else{
- XL_LOG(ctx, XL_LOG_WARNING,
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING,
"Unknown PCI BDF option: %s", optkey);
}
tok = ptr + 1;
if (!back)
return ERROR_NOMEM;
- XL_LOG(ctx, XL_LOG_DEBUG, "Creating pci backend");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Creating pci backend");
/* add pci device */
device.backend_devid = 0;
if (!num_devs)
return libxl_create_pci_backend(gc, domid, pcidev, 1);
- if (!is_hvm(ctx, domid)) {
+ if (!libxl__domain_is_hvm(ctx, domid)) {
if (libxl__wait_for_backend(ctx, be_path, "4") < 0)
return ERROR_FAIL;
}
if (!back)
return ERROR_NOMEM;
- XL_LOG(ctx, XL_LOG_DEBUG, "Adding new pci device to xenstore");
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Adding new pci device to xenstore");
num = atoi(num_devs);
flexarray_set(back, boffset++, libxl__sprintf(gc, "key-%d", num));
flexarray_set(back, boffset++, libxl__sprintf(gc, PCI_BDF, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func));
return ERROR_INVAL;
num = atoi(num_devs);
- if (!is_hvm(ctx, domid)) {
+ if (!libxl__domain_is_hvm(ctx, domid)) {
if (libxl__wait_for_backend(ctx, be_path, "4") < 0) {
- XL_LOG(ctx, XL_LOG_DEBUG, "pci backend at %s is not ready", be_path);
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path);
return ERROR_FAIL;
}
}
}
}
if (i == num) {
- XL_LOG(ctx, XL_LOG_ERROR, "Couldn't find the device on xenstore");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Couldn't find the device on xenstore");
return ERROR_INVAL;
}
if (errno == EAGAIN)
goto retry_transaction;
- if (!is_hvm(ctx, domid)) {
+ if (!libxl__domain_is_hvm(ctx, domid)) {
if (libxl__wait_for_backend(ctx, be_path, "4") < 0) {
- XL_LOG(ctx, XL_LOG_DEBUG, "pci backend at %s is not ready", be_path);
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path);
return ERROR_FAIL;
}
}
dir = opendir(SYSFS_PCIBACK_DRIVER);
if ( NULL == dir ) {
if ( errno == ENOENT ) {
- XL_LOG(ctx, XL_LOG_ERROR, "Looks like pciback driver not loaded");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Looks like pciback driver not loaded");
}else{
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER);
}
libxl__free_all(&gc);
return ERROR_FAIL;
dir = opendir(SYSFS_PCI_DEV);
if ( NULL == dir ) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", SYSFS_PCI_DEV);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", SYSFS_PCI_DEV);
return -1;
}
path = libxl__sprintf(gc, "%s/" PCI_BDF, SYSFS_PCIBACK_DRIVER, dom, bus, dev, func);
if ( lstat(path, &st) ) {
if ( errno == ENOENT )
- XL_LOG(ctx, XL_LOG_ERROR, PCI_BDF " is not assigned to pciback driver",
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, PCI_BDF " is not assigned to pciback driver",
dom, bus, dev, func);
else
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't lstat %s", path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't lstat %s", path);
closedir(dir);
return -1;
}
char *state, *vdevfn;
int rc, hvm;
- hvm = is_hvm(ctx, domid);
+ hvm = libxl__domain_is_hvm(ctx, domid);
if (hvm) {
if (libxl__wait_for_device_model(ctx, domid, "running", NULL, NULL) < 0) {
return ERROR_FAIL;
vdevfn = libxl__xs_read(gc, XBT_NULL, path);
path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
if ( rc < 0 )
- XL_LOG(ctx, XL_LOG_ERROR, "qemu refused to add device: %s", vdevfn);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "qemu refused to add device: %s", vdevfn);
else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) != 1 )
rc = -1;
xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
int i;
if (f == NULL) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
return ERROR_FAIL;
}
for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
if (flags & PCI_BAR_IO) {
rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 1);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: xc_domain_ioport_permission error 0x%llx/0x%llx", start, size);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "Error: xc_domain_ioport_permission error 0x%llx/0x%llx", start, size);
fclose(f);
return ERROR_FAIL;
}
rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
(size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 1);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: xc_domain_iomem_permission error 0x%llx/0x%llx", start, size);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "Error: xc_domain_iomem_permission error 0x%llx/0x%llx", start, size);
fclose(f);
return ERROR_FAIL;
}
pcidev->bus, pcidev->dev, pcidev->func);
f = fopen(sysfs_path, "r");
if (f == NULL) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
goto out;
}
if ((fscanf(f, "%u", &irq) == 1) && irq) {
rc = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: xc_physdev_map_pirq irq=%d", irq);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "Error: xc_physdev_map_pirq irq=%d", irq);
fclose(f);
return ERROR_FAIL;
}
rc = xc_domain_irq_permission(ctx->xch, domid, irq, 1);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: xc_domain_irq_permission irq=%d", irq);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "Error: xc_domain_irq_permission irq=%d", irq);
fclose(f);
return ERROR_FAIL;
}
if (!libxl_is_stubdom(ctx, domid, NULL)) {
rc = xc_assign_device(ctx->xch, domid, pcidev->value);
if (rc < 0 && (hvm || errno != ENOSYS)) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_assign_device failed");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_assign_device failed");
return ERROR_FAIL;
}
}
char *buf = libxl__sprintf(gc, PCI_BDF, domain, bus, dev, func);
rc = write(fd, buf, strlen(buf));
if (rc < 0)
- XL_LOG(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);
close(fd);
return rc < 0 ? rc : 0;
}
if (errno != ENOENT)
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access pciback path %s", reset);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access pciback path %s", reset);
reset = libxl__sprintf(gc, "%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, func);
fd = open(reset, O_WRONLY);
if (fd > 0) {
rc = write(fd, "1", 1);
if (rc < 0)
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "write to %s returned %d", reset, rc);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);
close(fd);
return rc < 0 ? rc : 0;
}
if (errno == ENOENT) {
- XL_LOG(ctx, XL_LOG_ERROR, "The kernel doesn't support PCI device reset from sysfs");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "The kernel doesn't support PCI device reset from sysfs");
} else {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access reset path %s", reset);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access reset path %s", reset);
}
return -1;
}
rc = get_all_assigned_devices(&gc, &assigned, &num_assigned);
if ( rc ) {
- XL_LOG(ctx, XL_LOG_ERROR, "cannot determine if device is assigned, refusing to continue");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot determine if device is assigned, refusing to continue");
goto out;
}
if ( is_assigned(assigned, num_assigned, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func) ) {
- XL_LOG(ctx, XL_LOG_ERROR, "PCI device already attached to a domain");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device already attached to a domain");
rc = ERROR_FAIL;
goto out;
}
if ( pcidev->vfunc_mask == LIBXL_PCI_FUNC_ALL ) {
if ( !(pcidev->vdevfn >> 3) ) {
- XL_LOG(ctx, XL_LOG_ERROR, "Must specify a v-slot for multi-function devices");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Must specify a v-slot for multi-function devices");
rc = ERROR_INVAL;
goto out;
}
if ( !libxl_device_pci_list_assigned(ctx, &assigned, domid, &num) ) {
if ( !is_assigned(assigned, num, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func) ) {
- XL_LOG(ctx, XL_LOG_ERROR, "PCI device not attached to this domain");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device not attached to this domain");
return ERROR_INVAL;
}
}
libxl_device_pci_remove_xenstore(gc, domid, pcidev);
- hvm = is_hvm(ctx, domid);
+ hvm = libxl__domain_is_hvm(ctx, domid);
if (hvm) {
if (libxl__wait_for_device_model(ctx, domid, "running", NULL, NULL) < 0) {
return ERROR_FAIL;
if ( (pcidev->vdevfn & 0x7) == 0 ) {
xs_write(ctx->xsh, XBT_NULL, path, "pci-rem", strlen("pci-rem"));
if (libxl__wait_for_device_model(ctx, domid, "pci-removed", NULL, NULL) < 0) {
- XL_LOG(ctx, XL_LOG_ERROR, "Device Model didn't respond in time");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model didn't respond in time");
return ERROR_FAIL;
}
}
int i;
if (f == NULL) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
goto skip1;
}
for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
if (flags & PCI_BAR_IO) {
rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 0);
if (rc < 0)
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_ioport_permission error 0x%x/0x%x", start, size);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_ioport_permission error 0x%x/0x%x", start, size);
} else {
rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
(size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 0);
if (rc < 0)
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_iomem_permission error 0x%x/0x%x", start, size);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_iomem_permission error 0x%x/0x%x", start, size);
}
}
}
pcidev->bus, pcidev->dev, pcidev->func);
f = fopen(sysfs_path, "r");
if (f == NULL) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
goto out;
}
if ((fscanf(f, "%u", &irq) == 1) && irq) {
rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_physdev_map_pirq irq=%d", irq);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_physdev_map_pirq irq=%d", irq);
}
rc = xc_domain_irq_permission(ctx->xch, domid, irq, 0);
if (rc < 0) {
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_irq_permission irq=%d", irq);
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_irq_permission irq=%d", irq);
}
}
fclose(f);
if (!libxl_is_stubdom(ctx, domid, NULL)) {
rc = xc_deassign_device(ctx->xch, domid, pcidev->value);
if (rc < 0 && (hvm || errno != ENOSYS))
- XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_deassign_device failed");
+ LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_deassign_device failed");
}
stubdomid = libxl_get_stubdom_id(ctx, domid);
if (r) {
if (errno == ENOENT) return 0; /* ok */
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to rotate logfile - could not"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to rotate logfile - could not"
" rename %s to %s", old, new);
return ERROR_FAIL;
}
goto out;
} else {
if (errno != ENOENT)
- XL_LOG_ERRNO(ctx, XL_LOG_WARNING, "problem checking existence of"
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_WARNING, "problem checking existence of"
" logfile %s, which might have needed to be rotated",
name);
}
f = fopen(filename, "r");
if (!f) {
if (errno == ENOENT) return ENOENT;
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to open %s", filename);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to open %s", filename);
goto xe;
}
if (fstat(fileno(f), &stab)) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to fstat %s", filename);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to fstat %s", filename);
goto xe;
}
if (!S_ISREG(stab.st_mode)) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "%s is not a plain file", filename);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "%s is not a plain file", filename);
errno = ENOTTY;
goto xe;
}
if (stab.st_size > INT_MAX) {
- XL_LOG(ctx, XL_LOG_ERROR, "file %s is far too large", filename);
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "file %s is far too large", filename);
errno = EFBIG;
goto xe;
}
rs = fread(data, 1, datalen, f);
if (rs != datalen) {
if (ferror(f))
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to read %s", filename);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to read %s", filename);
else if (feof(f))
- XL_LOG(ctx, XL_LOG_ERROR, "%s changed size while we"
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "%s changed size while we"
" were reading it", filename);
else
abort();
if (fclose(f)) {
f = 0;
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to close %s", filename);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to close %s", filename);
goto xe;
}
if (got == -1) { \
if (errno == EINTR) continue; \
if (!ctx) return errno; \
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to " #rw " %s%s%s", \
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to " #rw " %s%s%s", \
what?what:"", what?" from ":"", filename); \
return errno; \
} \
if (got == 0) { \
if (!ctx) return EPROTO; \
- XL_LOG(ctx, XL_LOG_ERROR, \
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, \
zero_is_eof \
? "file/stream truncated reading %s%s%s" \
: "file/stream write returned 0! writing %s%s%s", \
pid = fork();
if (pid == -1) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "fork failed");
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fork failed");
return -1;
}
int libxl_pipe(libxl_ctx *ctx, int pipes[2])
{
if (pipe(pipes) < 0) {
- XL_LOG(ctx, XL_LOG_ERROR, "Failed to create a pipe");
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Failed to create a pipe");
return -1;
}
return 0;
libxl_ctx *ctx = libxl_gc_owner(gc);
char *s = xs_get_domain_path(ctx->xsh, domid);
if (!s) {
- XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "failed to get dompath for %" PRIu32,
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to get dompath for %" PRIu32,
domid);
return NULL;
}